//
//  SABaseViewController.m
//  SunOn
//
//  Created by RazeenCheng on 2017/5/2.
//  Copyright © 2017年 NeoZhang. All rights reserved.
//

#import "SABaseViewController.h"

#import "SABaseNavigationController.h"

#import "SACollectionViewController.h"
#import "SAFeedbackViewController.h"
#import "SAQuestionnaireViewController.h"
#import "SADataShareViewController.h"
#import "SAPersonalViewController.h"

@interface SABaseViewController ()

@end

@implementation SABaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupViewControllers];
    [self configTabbarItem];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (void)setupViewControllers {
    // 信息收集
    UIStoryboard *collection = [UIStoryboard storyboardWithName:@"Collection" bundle:nil];
    SACollectionViewController *collectionVC = [collection instantiateViewControllerWithIdentifier:@"SACollectionViewController"];
    SABaseNavigationController *nav1 = [[SABaseNavigationController alloc] initWithRootViewController:collectionVC];
    
    // 咨询反馈
    UIStoryboard *feedback = [UIStoryboard storyboardWithName:@"Feedback" bundle:nil];
    SAFeedbackViewController *feedbackVC = [feedback instantiateViewControllerWithIdentifier:@"SAFeedbackViewController"];
    SABaseNavigationController *nav2 = [[SABaseNavigationController alloc] initWithRootViewController:feedbackVC];
    
    // 问卷调查
    UIStoryboard *questionnaire = [UIStoryboard storyboardWithName:@"Questionnaire" bundle:nil];
    SAQuestionnaireViewController *questionnaireVC = [questionnaire instantiateViewControllerWithIdentifier:@"SAQuestionnaireViewController"];
    SABaseNavigationController *nav3 = [[SABaseNavigationController alloc] initWithRootViewController:questionnaireVC];
    
    // 数据共享
    UIStoryboard *dataShare = [UIStoryboard storyboardWithName:@"DataShare" bundle:nil];
    SADataShareViewController *dataShareVC = [dataShare instantiateViewControllerWithIdentifier:@"SADataShareViewController"];
    SABaseNavigationController *nav4 = [[SABaseNavigationController alloc] initWithRootViewController:dataShareVC];
    
    // 个人中心
    UIStoryboard *personal = [UIStoryboard storyboardWithName:@"Personal" bundle:nil];
    SAPersonalViewController *personalVC = [personal instantiateViewControllerWithIdentifier:@"SAPersonalViewController"];
    SABaseNavigationController *nav5 = [[SABaseNavigationController alloc] initWithRootViewController:personalVC];
    
    self.viewControllers = [NSArray arrayWithObjects:nav1, nav2, nav3, nav4, nav5, nil];
}

- (void)configTabbarItem {
    self.tabBar.shadowImage = [UIImage new];
    self.tabBar.translucent = NO;
    self.tabBar.opaque = YES;
    
    UITabBarItem * FirstTabBarItem = [[UITabBarItem alloc] initWithTitle:@"信息收集"
                                                                   image:[UIImage imageNamed:@"TabBar-1-g"]
                                                           selectedImage:[UIImage imageNamed:@"TabBar-1-b"]];
    
    UITabBarItem * SecondTabBarItem = [[UITabBarItem alloc] initWithTitle:@"咨询反馈"
                                                                    image:[UIImage imageNamed:@"TabBar-2-g"]
                                                            selectedImage:[UIImage imageNamed:@"TabBar-2-b"]];
    
    UITabBarItem * ThirdTabBarItem = [[UITabBarItem alloc] initWithTitle:@"问卷调查"
                                                                   image:[UIImage imageNamed:@"TabBar-3-g"]
                                                           selectedImage:[UIImage imageNamed:@"TabBar-3-b"]];
    
    UITabBarItem * fourTabBarItem = [[UITabBarItem alloc] initWithTitle:@"数据共享"
                                                                  image:[UIImage imageNamed:@"TabBar-4-g"]
                                                          selectedImage:[UIImage imageNamed:@"TabBar-4-b"]];
    
    UITabBarItem * fiveTabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人中心"
                                                                  image:[UIImage imageNamed:@"TabBar-5-g"]
                                                          selectedImage:[UIImage imageNamed:@"TabBar-5-b"]];
    
    
    NSArray * itemArray = @[FirstTabBarItem,SecondTabBarItem,ThirdTabBarItem,fourTabBarItem,fiveTabBarItem];
    
    for (NSInteger i = 1; i <= itemArray.count ; i ++) {
        UIViewController *VC = self.viewControllers[i-1];
        
        UITabBarItem *item = [itemArray objectAtIndex:(i-1)];
        [item setTag:i];
        VC.tabBarItem = item;
    }
    
    //    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:select_Color_TabItem, NSForegroundColorAttributeName,[UIFont systemFontOfSize:13],NSFontAttributeName, nil] forState:UIControlStateSelected];
    //    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:normal_Color_TabItem, NSForegroundColorAttributeName,[UIFont systemFontOfSize:13],NSFontAttributeName, nil] forState:UIControlStateNormal];
    
    
    //    for(UITabBarItem *item in self.tabBar.items) {
    //        item.selectedImage = [item.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //        item.image = [item.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //    }
}

@end
